import { _FilterLayout } from '../../../../../../config.js';
export default {
	isJiess: true,
	name: 'FilterLayout',
	setup({
		buttons,
		isCollapse,
		boxStyle,
		filter,
		Collapse,
		CollapseItem,
		ActionButtons,
		showButtons = true,
	}) {
		const { model = 'divider' } = _FilterLayout;
		const classNames = ['filter-layout', model];
		if (!isCollapse) classNames.push('no-expand');
		this.add({
			style: boxStyle,
			className: classNames.join(' '),
			children: [
				(isCollapse ? {
					is: Collapse,
					children: {
						is: CollapseItem,
						children: [{
							slot: 'title',
							style: { width: '100%' },
							children: { $slot: 'default' },
							onClick: e => e.stopPropagation()
						}, {
							style: { width: '100%' },
							children: { $slot: 'expand' }
						}]
					}
				} : {
					style: { flex: 1 },
					children: { $slot: 'default' }
				}),
				// 右侧按钮区域
				{
					$if: showButtons,
					style: { margin: '0 36px 0 18px' },
					children: {
						is: ActionButtons,
						buttons: () => {
							return buttons ? buttons : [
								{ text: '搜索', onClick: filter.onSearch, type: 'primary' },
								{ text: '重置', onClick: filter.onReset }
							];
						}
					}
				}
			]
		})
	}
}